﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GN.Pay.Utils;

namespace GN.Pay.TradeChannel.DefaultImpl
{
    /// <summary>
    /// 默认交易订单查询结果
    /// </summary>
    [Serializable]
    public class TradeOrderQueryResult : ATradeChannelResult, ITradeOrderQueryResult
    {
        /// <summary>
        /// 实例化 TradeOrderQueryResult
        /// </summary>
        /// <param name="channel"></param>
        public TradeOrderQueryResult(IChannel channel) 
            : base(channel)
        {

        }        

        /// <summary>
        /// 获取订单号
        /// </summary>
        public string OrderNo { get; set; }

        /// <summary>
        /// 获取交易号
        /// </summary>
        public string TradeNo { get; set; }

        /// <summary>
        /// 付款时间
        /// </summary>
        public DateTime PayTime { get; set; }

        /// <summary>
        /// 订单金额
        /// </summary>
        public decimal OrderMoney { get; set; }

        /// <summary>
        /// 付款费用
        /// </summary>
        public decimal PayFee { get; set; }

        /// <summary>
        /// 已退款金额
        /// </summary>
        public decimal RefundMoney { get; set; }

        /// <summary>
        /// 已退款费用
        /// </summary>
        public decimal RefundFee { get; set; }

        /// <summary>
        /// 对方账号
        /// </summary>
        public string OtherPartyAccount { get; set; }

        /// <summary>
        /// 对方账号Id
        /// </summary>
        public string OtherPartyAccountId { get; set; }

        /// <summary>
        /// 银行类型
        /// </summary>
        public string BankType { get; set; }

        /// <summary>
        /// 银行名称
        /// </summary>
        public string BankName { get; set; }

        /// <summary>
        /// 通道模式
        /// </summary>
        public string ChannelMode { get; set; }

        /// <summary>
        /// 获取扩展参数
        /// </summary>
        public string ExtraParam { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        public string Subject { get; set; }

        /// <summary>
        /// 详情(体)
        /// </summary>
        public string Body { get; set; }

        /// <summary>
        /// 验证
        /// </summary>
        public void Validation()
        {
            if (string.IsNullOrWhiteSpace(this.OrderNo))
            {
                this.ThrowChannelValidationException
                  ("OrderNo 为 null 或空白");              
            }
            if (this.OrderMoney <= 0)
            {
                this.ThrowChannelValidationException
                  ("OrderMoney 小于或等于零");               
            }
            if (this.PayFee < 0)
            {
                this.ThrowChannelValidationException
                  ("PayFee 小于零");                
            }
            if (this.RefundMoney < 0)
            {
                this.ThrowChannelValidationException
                  ("RefundMoney 小于零");
            }
            if (this.RefundFee < 0)
            {
                this.ThrowChannelValidationException
                   ("RefundFee 小于零");
            }
        }

       
    }
}
